// Learn TypeScript:
//  - https://docs.cocos.com/creator/manual/en/scripting/typescript.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

const {ccclass, property} = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {

    
    onLoad () {
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.moveHandler, this)
    }

    start () {

    }

    moveHandler(e: cc.Event.EventTouch){
        const delta: cc.Vec2 = e.getDelta(); //获取触点距离上一次事件移动的距离对象，对象包含 x 和 y 属性
        this.node.x += delta.x;
        this.node.y += delta.y
    }

    // update (dt) {}

    onCollisionEnter(other: cc.Collider, self: cc.Collider){
        cc.log(`player：${other.node.name} ${self.node.name}`)
    }

    onCollisionStay(other, self){

    }

    onCollisionExit(other, self){
        
    }
}
